<?php
namespace Common\Model;
use Think\Model;

class CommonNavModel extends Model{
	//模型对象表名称
	protected $tableName = 'common_nav';

	protected $_auto = array(
		array('creattime','time',1,'function'),
		array('updatetime','time',3,'function')
	);

	public function getListByMap($condition='',$limit='100',$order='id asc'){
		$data = $this->where($condition)->limit($limit)->order($order)->select();
		return $data;
	}
	/*
	 * name   : 增加导航菜单
	 * author : ycgpp@126.com
	 */
	public function addNav($data){
		$result = $this->add($data);
		return $result;
	}
	/*
	 * name   : 修改保存导航菜单
	 * author : ycgpp@126.com
	 */
	public function saveNav($condition,$data){
		$result = $this->where($condition)->save($data);
		return $result;
	}
	/*
	 * name   : 删除导航菜单
	 * author : ycgpp@126.com
	 * @return param $id  主键ID
	 */
	public function delNav($id){
		$result = $this->where('id = '.$id)->delete();
		$re = $this->where("pid=".$id)->find();
		if($re && $result){
			$result = $this->where("pid=".$id)->delete();
		}
		return $result;
	}
}
?>